<?php

namespace Core;

use Core\Model\Album;
 use Core\Model\AlbumTable;
 use Zend\Db\ResultSet\ResultSet;
 use Zend\Db\TableGateway\TableGateway;

class Module {

    public function getConfig() {
        return include __DIR__ . '/config/module.config.php';
    }

    public function getAutoloaderConfig() {
        return array(
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ),
            ),
        );
    }

    public function getServiceConfig() {
        return array(
            'factories' => array(
                'Core\Model\AlbumTable' => function($sm) {
            $tableGateway = $sm->get('AlbumTableGateway');
            $table = new AlbumTable($tableGateway);
            return $table;
        },
                'AlbumTableGateway' => function ($sm) {
            $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
            $resultSetPrototype = new ResultSet();
            $resultSetPrototype->setArrayObjectPrototype(new Album());
            return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
        },
            ),
        );
    }

}
